package com.cqie.hospitalescort.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cqie.hospitalescort.entity.City;
import com.cqie.hospitalescort.mapper.CityMapper;
import com.cqie.hospitalescort.service.CityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 基础表-省市区 服务实现类
 * </p>
 *
 * @author gdy
 * @since 2025-02-18
 */
@Service
public class CityServiceImpl extends ServiceImpl<CityMapper, City> implements CityService {

    @Autowired
    private CityMapper cityMapper;

    /**
     * 根据父级ID获取所有直接子级地址。
     *
     * @param parentId 父级ID。
     * @return 子级地址列表。
     */
    @Override
    public List<City> getChildrenByParentId(Integer parentId) {
        return cityMapper.selectList(new LambdaQueryWrapper<City>().eq(City::getParentId, parentId));
    }

}
